package com.cheil.publish.service.ai;

import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;

/**
 * @author ssk
 * @date 2025/9/5
 **/
@Component
@AllArgsConstructor
@Log4j2
public class OpenAiService {

    private final OpenAiChatModel openAiChatModel;

    public Flux<String> chat(String prompt) {
        ChatClient chatClient = ChatClient.builder(openAiChatModel)
                .defaultSystem("你是一个专业内容文案助手")
                .defaultUser(prompt)
                .build();
        return chatClient
                .prompt()
                .stream()
                .content();
    }


}
